#!/bin/bash

# 更新包索引
sudo apt-get update

# 定义要安装的包列表
packages=(
    "make"
    "g++"
    "flex"
    "bison"
    "libncurses5-dev"
    "libmpc-dev"
    "libgmp-dev"
    "libmpfr-dev"
)

# 检查并安装每个包
for pkg in "${packages[@]}"; do
    if dpkg -s "$pkg" >/dev/null 2>&1; then
        echo "包 '$pkg' 已安装"
    else
        echo "安装包 '$pkg'..."
        sudo apt-get install -y "$pkg"
    fi
done